<footer id="footer">
    <div>
        &copy; {{ now.Format "2006" }} <a href="{{ .Site.BaseURL | absURL }}">{{ .Site.Title }} By {{ .Site.Author.name }}</a>
        {{ if .Site.Params.beian }}
        | <a rel="nofollow" target="_blank" href="http://beian.miit.gov.cn/">{{.Site.Params.beian}}</a>
        {{ end }}
    </div>
    <br />
    <div>
        <div class="github-badge">
            <a href="https://gohugo.io/" target="_black" rel="nofollow"><span class="badge-subject">Powered by</span><span class="badge-value bg-blue">Hugo</span></a>
        </div>
        <div class="github-badge">
            <a href="https://github.com/flysnow-org/maupassant-hugo" target="_black"><span class="badge-subject">Theme</span><span class="badge-value bg-yellowgreen">Maupassant</span></a>
        </div>
    </div>
</footer>

{{ if .IsPage }}
    <!-- graphviz -->
    {{- if and (or .Params.graphviz.enable (and .Site.Params.graphviz.enable (ne .Params.graphviz.enable false))) (or .IsPage .IsHome) -}}
        <script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/viz.js/1.7.1/viz.js"></script>
        <script type="text/javascript">
            (function () {
                if (!window.Viz) return;
                var vizPrefix = "language-viz-";
                var i = 0;
                Array.prototype.forEach.call(document.querySelectorAll("code[class^=" + vizPrefix + "]"), function (block) {
                    var engine;
                    block.getAttribute("class").split(" ").forEach(function (cls) {
                        if (cls.startsWith(vizPrefix)) {
                            engine = cls.substr(vizPrefix.length);
                        }
                    });
                    const rootElement = block.parentNode;
                    var image = new DOMParser().parseFromString(Viz(block.innerText, { format: "svg", engine: engine }), "image/svg+xml");
                    const container = document.createElement('div');
                    container.className = 'align-center';
                    container.setAttribute("style", "overFlow-x:auto");
                    container.appendChild(image.documentElement);
                    rootElement.parentNode.replaceChild(container, rootElement);
                });
            })();
        </script>
    {{- end -}}

    <!-- flowchart -->
    {{- if and (or .Params.flowchartDiagrams.enable (and .Site.Params.flowchartDiagrams.enable (ne .Params.flowchartDiagrams.enable false))) (or .IsPage .IsHome) -}}
        <script src="//cdnjs.cloudflare.com/ajax/libs/raphael/2.2.8/raphael.min.js" crossorigin="anonymous"></script>
        <script src="//cdnjs.cloudflare.com/ajax/libs/flowchart/1.12.2/flowchart.min.js" crossorigin="anonymous"></script>
        <script>
            {{- if .Params.flowchartDiagrams.options -}}
                window.flowchartDiagramsOptions = {{ .Params.flowchartDiagrams.options | safeJS }};
            {{- else if .Site.Params.flowchartDiagrams.options -}}
                window.flowchartDiagramsOptions = {{ .Site.Params.flowchartDiagrams.options | safeJS }};
            {{- end -}}
            (function () {
                if (!window.flowchart) return;
                const blocks = document.querySelectorAll('pre code.language-flowchart, pre code.language-flow');
                for (let i = 0; i < blocks.length; i++) {
                    const block = blocks[i];
                    const rootElement = block.parentNode;
                    const container = document.createElement('div');
                    const id = `js-flowchart-diagrams-${i}`;
                    container.id = id;
                    container.className = 'align-center';
                    container.setAttribute("style", "overFlow-x:auto");
                    rootElement.parentNode.replaceChild(container, rootElement);
                    const diagram = flowchart.parse(block.childNodes[0].nodeValue);
                    diagram.drawSVG(id, window.flowchartDiagramsOptions ? window.flowchartDiagramsOptions : {});
                }
            })();
        </script>
    {{- end -}}
    
    <!-- sequence必须要在flow加载之后，否则sequence渲染不成功，原因待分析 -->
    <!-- js-sequence-diagrams -->
    {{- if and (or .Params.sequenceDiagrams.enable (and .Site.Params.sequenceDiagrams.enable (ne .Params.sequenceDiagrams.enable false))) (or .IsPage .IsHome) -}}
        <script src="//cdnjs.cloudflare.com/ajax/libs/webfont/1.6.28/webfontloader.js" crossorigin="anonymous"></script>
        <script src="//cdnjs.cloudflare.com/ajax/libs/snap.svg/0.5.1/snap.svg-min.js" crossorigin="anonymous"></script>
        <script src="//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.9.1/underscore-min.js" crossorigin="anonymous"></script>
        <script src="//cdnjs.cloudflare.com/ajax/libs/js-sequence-diagrams/1.0.6/sequence-diagram-min.js" crossorigin="anonymous"></script>
        <script>
        {{- if .Params.sequenceDiagrams.options -}}
            window.sequenceDiagramsOptions = {{ .Params.sequenceDiagrams.options | safeJS }};
        {{- else if .Site.Params.sequenceDiagrams.options -}}
            window.sequenceDiagramsOptions = {{ .Site.Params.sequenceDiagrams.options | safeJS }};
        {{- end -}}
        (function () {
            if (!window.Diagram) return;
            const blocks = document.querySelectorAll('pre code.language-sequence');
            for (let i = 0; i < blocks.length; i++) {
                const block = blocks[i];
                // const rootElement = window.Prism.plugins.lineNumbers ? (window.Prism.plugins.toolbar ? block.parentElement.parentElement : block.parentElement) : block;
                const rootElement = block.parentNode;
                const container = document.createElement('div');
                const id = `js-sequence-diag-${i}`;
                container.id = id;
                container.className = 'align-center';
                container.setAttribute("style", "overFlow-x:auto");
                rootElement.parentNode.replaceChild(container, rootElement);

                const diagram = Diagram.parse(block.childNodes[0].nodeValue);
                diagram.drawSVG(id, window.sequenceDiagramsOptions
                    ? window.sequenceDiagramsOptions
                    : { theme: 'simple' });
            }
        })();
        </script>
    {{- end -}}
    
    <script type="text/javascript">
        window.MathJax = {
            tex2jax: {
                inlineMath: [['$', '$']],
                processEscapes: true
                }
            };
    </script>
    <script src='https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-MML-AM_CHTML' async></script>
    
    {{- if .Site.Params.fancybox -}}
        <script src="https://cdn.bootcdn.net/ajax/libs/fancybox/3.5.7/jquery.fancybox.min.js"></script>
    {{- end -}}
{{ end }}

<a id="rocket" href="#top"></a>
<script type="text/javascript" src='{{ "js/totop.js?v=0.0.0" | relURL }}' async=""></script>
{{ template "_internal/google_analytics_async.html" . }}

{{ if .Site.Params.busuanzi }}
    <script type="text/javascript" src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js" async></script>
{{ end }}

<!-- custom js -->
{{ range .Site.Params.customJS }}
    <script src='{{ "/js/" | relURL }}{{ . }}'></script>
{{ end }}